﻿using System;
using System.Linq;

namespace ObjectMapper.Benchmark
{
    public class BLToolkitExecutor:IMapExecutor
    {
        public string Name
        {
            get
            {
                return "BLToolkit";
            }
        }

        public void Initialize()
        {
        }

        public void PreExecute<TSource, TTarget>()
        {
            BLToolkit.Mapping.Map.ObjectToObject<TTarget>(Activator.CreateInstance<TSource>());
        }

        public TTarget[] Execute<TSource, TTarget>(TSource[] entities)
        {
            return entities == null
                ? null
                : entities.Select(entity => BLToolkit.Mapping.Map.ObjectToObject<TTarget>(entity)).ToArray();
        }

        public void PostExecute<TSource, TTarget>()
        {
        }
    }
}
